define(["angularAMD", "moment"], function (angularAMD, moment) {
    angularAMD.service('$MaterialStation',
       ['$rootScope', '$filter', '$translate', 'config', 'MMWService', '$mdDialog',
        function ($rootScope, $filter, $translate, config, $MMWService, $mdDialog) {
            var service = this;
            service.init = function(options){
                (function openDialog(){
                    $mdDialog.dialog(
                        'module/moduleMobileSMT/program/SMT02/MaterialStation.tmp.html',
                        function (dialog) {
                            return {
                                css_url:'module/moduleMobileSMT/program/SMT02/MaterialStation.css',
                                beforeShown:function(){
                                    if(options.content){
                                        dialog.feeding_record_info_get(options.content,function(data){
                                            if(data && data.mfu_check_list_data.length > 0){
                                                data.mfu_check_list_data.some(function(item){
                                                    if((+item.remain_time) <= 0 && item.remain_time != "-0.1"){
                                                        $rootScope.showAlert($filter('translate')('SMT03.msg.acces_need_to_dry'));
                                                    }
                                                })
                                                dialog.MaterialStationList = data.mfu_check_list_data;
                                            } else {
                                                dialog.MaterialStationList = [];
                                            };
                                        })
                                    }
                                },
                                data:options.data,
                                content:options.content,
                                feeding_record_info_get:options.feeding_record_info_get,
                                MaterialStationList:options.itmeList,
                                back:function(){
                                    dialog.hide();
                                },
                            }
                        }
                    );
                })();
            };

        }]);
});
